import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;


public class SaeifB {

	private BurningForstSimulation simulation;
	
	private double g=0.5;
	private double f=0.5;
	private double p=0.5;
	
	
	public void startTest() throws IOException {
        BufferedWriter out = new BufferedWriter(new FileWriter("out.txt"));
        System.out.println("--------------CHECK G------------");
        out.write("--------------CHECK G------------");
        g=0.0;
        f=0.5;
        p=0.5;
                
		while (g <=1.05){
			doSimulation();
			double measure = simulation.getGlobalMeasure();
			double measureLocal = simulation.getLocalMeasure();
			System.out.println("g="+g + " global measure is  " +measure+"    local measure is  " +measureLocal );
	        out.write("g="+g + " global measure is  " +measure+"    local measure is  " +measureLocal);
	        out.newLine();	
			g = g+0.05;
			
		}
		
		System.out.println("--------------CHECK F------------");
		out.write("--------------CHECK F------------");
        g=0.5;
        f=0.0;
        p=0.5;
                
		while (f <=1.05){
			doSimulation();
			double measure = simulation.getGlobalMeasure();
			double measureLocal = simulation.getLocalMeasure();
			System.out.println("f="+f + " global measure is  " +measure +"    local measure is  " +measureLocal );
	        out.write("f="+f + " global measure is  " +measure+"    local measure is  " +measureLocal);
	        out.newLine();	
			f = f+0.05;
			
		}
		
		System.out.println("--------------CHECK P------------");
		out.write("--------------CHECK P------------");
        g=0.5;
        f=0.5;
        p=0.0;
                
		while (p <=1.05){
			doSimulation();
			double measure = simulation.getGlobalMeasure();
			double measureLocal = simulation.getLocalMeasure();
			System.out.println("p="+p + " global measure is  " +measure+"    local measure is  " +measureLocal);
	        out.write("p="+p + " global measure is  " +measure+"    local measure is  " +measureLocal);
	        out.newLine();	
			p = p+0.05;
			
		}
		
		out.flush();
		out.close();
	}
	private void doSimulation() {
		simulation=  new BurningForstSimulation();
		simulation.d_plantingProb=0.5;
		simulation.f_lightningStrikeProb=f;
		simulation.p_growNewPlantProb=p;
		simulation.g_combustibilityProb=g;
		
		simulation.initCellularAutomatonWithTreesCol();
		
		int gen = 0;
		while (gen<Constants.GENERATION_LIMIT) {
			simulation.evolveToNextGeneration();
			gen++;
		}
		
	}
}
